package com.wl.mr.group;

import org.apache.hadoop.io.WritableComparable;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;

public class GroupBean implements WritableComparable<GroupBean> {

    private String orderId;
    private Double privece;

    @Override
    public int compareTo(GroupBean o) {
        int res = this.orderId.compareTo(o.orderId);
        if(res == 0 ){
            res = -this.privece.compareTo(o.privece);
        }

        return res;
    }

    @Override
    public void write(DataOutput out) throws IOException {
        out.writeUTF(orderId);
        out.writeDouble(privece);
    }

    @Override
    public void readFields(DataInput in) throws IOException {
        in.readUTF();
        in.readDouble();
    }

    public GroupBean() {
    }

    public String getOrderId() {
        return orderId;
    }

    public void setOrderId(String orderId) {
        this.orderId = orderId;
    }

    public Double getPrivece() {
        return privece;
    }

    public void setPrivece(Double privece) {
        this.privece = privece;
    }

    @Override
    public String toString() {
        return orderId + '\t' + privece ;
    }
}
